package com.yima.baseproj.module.app.equipmentUser;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yima.baseproj.module.app.equipmentUser.model.*;
import com.yima.baseproj.module.app.user.AppUserEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class EquipmentUserService extends ServiceImpl<EquipmentUserMapper, EquipmentUserEntity> {
    public EquipmentUserEntity findByMpWeixinOpenId(String mpWeixinOpenId) {
        return getOne(Wrappers.<EquipmentUserEntity>query().eq("openid",mpWeixinOpenId));
    }

    public Page<Map> findByPage(Page page, EquipmentUserSearchModel searchVo) {
        return baseMapper.findBySearchVo(page, searchVo);
    }

    public List<Map> findByList(EquipmentUserSearchModel searchVo) {
        return baseMapper.findBySearchVo(searchVo);
    }

    /**
     * 添加 - 事务
     *
     * @param paramModel
     */
    @Transactional(rollbackFor = Exception.class)
    public void add(EquipmentUserAddParamModel paramModel) {

    }

    @Transactional(rollbackFor = Exception.class)
    public void edit(EquipmentUserEditParamModel paramModel) {

    }

    @Transactional(rollbackFor = Exception.class)
    public void dels(String[] ids) {
        baseMapper.deleteBatchIds(Arrays.asList(ids));
    }
}